﻿using System;
using System.Collections.Generic;

/// <summary>
/// 卡牌属性基类
/// </summary>
[Serializable]
public class PropertyBase
{
    public string className = "";
    //方便管理 所有可选属性
    public List<PropertyValue<object>> propertyList = new List<PropertyValue<object>>();

    public PropertyBase(){
        className = this.GetType().FullName;
    }
    
    public virtual bool IsContain(PropertyValue<object> val)
    {
        foreach(var item in propertyList){
            if(item.discript == val.discript) return true;
        }
        return false;
    }
    /// <summary>
    /// 设置单个属性的值
    /// </summary>
    /// <param name="propertyListVal"></param>
    public virtual void InitData(List<PropertyValue<object>> propertyListVal)
    {
        for(int i = 0; i < propertyList.Count;i++){
            foreach(var item in propertyListVal){
                if(propertyList[i].discript == item.discript){
                   propertyList[i].InitData(item);
                }
            }
        }
    }
    /// <summary>
    /// 随机获取一个
    /// </summary>
    /// <returns></returns>
    virtual public PropertyValue<object> GetRandOne(){
        var random = new Random();
        var index = random.Next(0, propertyList.Count);
        return propertyList[index];
    }
}